<?php
require('functions/page_load.php');
require("fckeditor/fckeditor.php");

$content_nav = true;

if($_SERVER['REQUEST_METHOD'] == 'POST'){

$sql = "INSERT INTO content SET content = '".mysql_real_escape_string(stripslashes($_POST['category_content']))."', name = '".mysql_real_escape_string($_POST['name'])."', url = '".mysql_real_escape_string($_POST['url'])."', title = '".mysql_real_escape_string($_POST['title'])."', description = '".mysql_real_escape_string($_POST['description'])."'";
$query = mysql_query( $sql ) or die ("Error in query: $sql. " . mysql_error());
$new_id = mysql_insert_id();

header("Location: edit_page.php?new=true&id=".$new_id);

}

require('includes/header.php');
?>

<div class="side_container">
<h2 class="container_header">Navigation</h2>

<ul>
<li><a href="content.php">Pages</a></li>
<li><a href="blog.php">Blog</a></li>
<li><a href="directory.php">Directory</a></li>
<li><a href="faqs.php">FAQs</a></li>
</ul>

</div>

<div class="main_container_wrapper">

	<div class="main_container">
	<h2 class="container_header">Add page</h2>
	
	<?php echo $results; ?>
	
	<form method="post" action="">
	
	<div class="form_row_wrapper">
	<div class="form_row_left"><label for="name">Page name*:</label></div>
	<div class="form_row_right"><input type="text" name="name" id="name" value="<?php echo $rs['name']; ?>" onkeyup="buildUrl();" onkeydown="buildUrl();" /></div>
	</div>

	<div class="form_row_wrapper">
	<div class="form_row_left"><label for="url">Page URL*:</label></div>
	<div class="form_row_right"><input type="text" name="url" id="url" value="<?php echo $rs['url']; ?>" /> <span>This must be a unique and web-safe name for the page.</span></div>
	</div>
	
	<div class="form_row_wrapper">
	<div class="form_row_left"><label for="title">Page title:</label></div>
	<div class="form_row_right"><input type="text" name="title" id="title" value="" /></div>
	</div>

	<div class="form_row_wrapper">
	<div class="form_row_left"><label for="description">Page description:</label></div>
	<div class="form_row_right"><textarea name="description" id="description" rows="5" cols="30"></textarea></div>
	</div>
	
	<div class="form_row_wrapper">
	<div class="form_row_left"><label>Content:</label></div>
	<div class="form_row_right">
	<?php
	$oFCKeditor = new FCKeditor('category_content');
	$oFCKeditor->Height = '400';
	$oFCKeditor->BasePath = '/admin/fckeditor/';
	$oFCKeditor->Value = $rs['content'];
	$oFCKeditor->Create();
	?>
	</div>
	</div>
	
	<div class="form_row_wrapper">
	<div class="form_row_left">&nbsp;</div>
	<div class="form_row_right"><input type="image" src="images/save_button.png" alt="Save" /></div>
	</div>
	
	</form>

	</div>

</div>
	
<?php
	require('includes/footer.php');
?>